#ifndef LEAMQTSTREAMHH
#define LEAMQTSTREAMHH
#include "stdincludes.hh"
#include "leam-in-stream.hh"
#include "leam-out-stream.hh"

class QAbstractSocket;

namespace leam
{
    class LeamQAbstractSocketInStream : public ILeamInStream
    {
	QAbstractSocket* socket;
	licada::TDataVector ignoreBuffer;
    public:
	LeamQAbstractSocketInStream() : socket(NULL){}
	virtual ~LeamQAbstractSocketInStream(){}
	void setup( QAbstractSocket* _socket ) {
	    socket = _socket;
	}
	virtual bool hasData();
	virtual void operator>>( licada::uint8& val );
	virtual void operator>>( licada::uint16& val );
	//message id, length
	virtual void operator>>( licada::uint32& val );
	//Write this as if it was a data vector, and don't write the null
	//character at the end.
	virtual void operator>> ( std::string& val );
	//pre-allocated, read up to data.size bytes
	virtual void operator>>( licada::TDataVector& data );
	virtual void ignore( licada::uint32 numBytes );
	virtual void close();
    private:
	//blocking read.
	void readBytes( char* buffer, licada::uint32 length );
    };
    
    class LeamQAbstractSocketOutStream : public ILeamOutStream
    {
	QAbstractSocket* socket;

    public:
	LeamQAbstractSocketOutStream() : socket ( NULL ){}
	virtual ~LeamQAbstractSocketOutStream(){}
	virtual void setup( QAbstractSocket* _socket ) {
	    socket = _socket;
	}
	virtual void operator<<( licada::uint8 val );
	virtual void operator<<( licada::uint16 val );
	virtual void operator<<( licada::uint32 val );
	//Read in characters placing directly into string.  Not sure
	//the c++ standard way of doing this exactly.  val.length()
	//should tell you the desired length.
	virtual void operator<<( const std::string& val );
	virtual void operator<<( const licada::TDataVector& data );
	virtual void flush();
	virtual void close();
    };
}
#endif
